package gui;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import Controlador.Controlador;
import Controlador.ControladorRodamiento;
import beans.Rodamiento;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class EliminarRodamientoFrame extends Vista {
	
	
	{
		//Set Look & Feel
		try {
			javax.swing.UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

	private JFrame ventana = new JFrame();
	
	

	public static void main(String[] args) {
		EliminarRodamientoFrame m = new EliminarRodamientoFrame();
		Controlador rodamiento=new ControladorRodamiento(m);
		m.addcontroladorrodamiento(rodamiento);
		
	} 
	

	public EliminarRodamientoFrame()
	{
		super();
		initGUI();
	}
	

	private void initGUI() {
		try {
			{
				jPanel1 = new JPanel();
				ventana.getContentPane().add(jPanel1, BorderLayout.CENTER);
				jPanel1.setLayout(null);
				jPanel1.setPreferredSize(new java.awt.Dimension(308, 143));
				ventana.setTitle("Elimnar Rodamiento");
				{
					lblRodamiento = new JLabel();
					jPanel1.add(lblRodamiento);
					lblRodamiento.setBounds(12, 26, 85, 16);
					lblRodamiento.setText("Codigo:");
				}
				{
					txtRodamiento = new JTextField();
					jPanel1.add(txtRodamiento);
					txtRodamiento.setBounds(109, 24, 134, 20);
				}
				{
					btnEliminar = new JButton();
					jPanel1.add(btnEliminar);
					btnEliminar.setText("Eliminar");
					btnEliminar.setBounds(55, 96, 94, 26);
					btnEliminar.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							btnEliminarActionPerformed(evt);
						}
					});
				}
				{
					btnCancelar = new JButton();
					jPanel1.add(btnCancelar);
					btnCancelar.setText("Cancelar");
					btnCancelar.setBounds(169, 96, 103, 26);
					btnCancelar.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							btnCancelarActionPerformed(evt);
						}
					});
				}
			}	
			ventana.setLocationRelativeTo(null);
			ventana.setVisible(true);
			ventana.pack();
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
	
	private void btnEliminarActionPerformed(ActionEvent evt) {
		Rodamiento roda;
		roda=((ControladorRodamiento)getControladorrodamientos()).buscarRodamiento(txtRodamiento.getText());
		if (roda!=null) {
		((ControladorRodamiento)getControladorrodamientos()).eliminarRodamiento(txtRodamiento.getText());
		txtRodamiento.setText("");
		}
	}
	
	private void btnCancelarActionPerformed(ActionEvent evt) {
		this.ventana.dispose();
	}
	private JPanel jPanel1;
	private JLabel lblRodamiento;
	private JButton btnCancelar;
	private JButton btnEliminar;
	private JTextField txtRodamiento;

}
